static
arglist_t arcdist_args[] = {
- {"file", &arcfileopt, "File containing vertices of arc"},
- {"distance", &distopt, "Maximum distance from arc"},
- {"exclude", &exclopt, "Exclude points close to the arc"},
- {0, 0, 0}
+ {"file", &arcfileopt, "File containing vertices of arc",
+ ARGTYPE_FILE | ARGTYPE_REQUIRED},
+ {"distance", &distopt, "Maximum distance from arc",
+ ARGTYPE_FLOAT | ARGTYPE_REQUIRED},
+ {"exclude", &exclopt, "Exclude points close to the arc", ARGTYPE_BOOL},
+ {0, 0, 0, 0}
};
static double gcdist( double lat1, double lon1, double lat2, double lon2 ) {
static
arglist_t cetus_args[] = {
- {"dbname", &dbname, "Database name"},
- {0, 0, 0}
+ {"dbname", &dbname, "Database name", ARGTYPE_STRING },
+ {0, 0, 0, 0 }
};
static void
void setshort_mustuniq(void *, int n);
void setshort_whitespace_ok(void *, int n);
+#define ARGTYPE_UNKNOWN 0
+#define ARGTYPE_INT 0x00000001
+#define ARGTYPE_FLOAT 0x00000002
+#define ARGTYPE_STRING 0x00000003
+#define ARGTYPE_BOOL 0x00000004
+#define ARGTYPE_FILE 0x00000005
+#define ARGTYPE_OUTFILE 0x00000006
+#define ARGTYPE_REQUIRED 0x40000000
+
+#define ARGTYPE_TYPEMASK 0x00000fff
+#define ARGTYPE_FLAGMASK 0xfffff000
+
typedef struct arglist {
char *argstring;
char **argval;
char *helpstring;
+ long argtype;
} arglist_t;
typedef struct ff_vecs {
static
arglist_t dup_args[] = {
- {"shortname", &snopt, "Suppress duplicate waypoints based on name"},
- {"location", &lcopt, "Suppress duplicate waypoint based on coords"},
- {0, 0, 0}
+ {"shortname", &snopt, "Suppress duplicate waypoints based on name",
+ ARGTYPE_BOOL},
+ {"location", &lcopt, "Suppress duplicate waypoint based on coords",
+ ARGTYPE_BOOL},
+ {0, 0, 0, 0}
};
static
arglist_t easygps_args[] = {
-/* {"deficon", &deficon, "Default icon name"}, */
- {0, 0, 0}
+/* {"deficon", &deficon, "Default icon name", ARGTYPE_STRING}, */
+ {0, 0, 0, 0 }
};
static void
printf(" %-20.20s %-50.50s\n",
vec->name, vec->desc);
for (ap = vec->vec->args; ap && ap->argstring; ap++) {
- printf(" %-18.18s %-.50s\n",
- ap->argstring, ap->helpstring);
+ printf(" %-18.18s %-.50s %s\n",
+ ap->argstring, ap->helpstring,
+ (ap->argtype&ARGTYPE_REQUIRED)?"(required)":"");
}
}
}
static
arglist_t my_args[] = {
- {"dbname", &dbname, "Database name"},
- {0, 0, 0}
+ {"dbname", &dbname, "Database name", ARGTYPE_STRING},
+ {0, 0, 0, 0}
};
static void
static
arglist_t gpspilot_args[] = {
- {"dbname", &dbname, "Database name"},
- {0, 0, 0}
+ {"dbname", &dbname, "Database name", ARGTYPE_STRING},
+ {0, 0, 0, 0}
};
static void
static FILE *ofd;
static void *mkshort_handle;
+static const char *input_string = NULL;
+static int input_string_len = 0;
+
static time_t file_time;
static char *gsshortnames = NULL;
void
gpx_rd_init(const char *fname, const char *args)
{
- fd = fopen(fname, "r");
- if (fd == NULL) {
- fatal(MYNAME ": Cannot open %s for reading\n", fname );
+ if ( fname[0] ) {
+ fd = fopen(fname, "r");
+ if (fd == NULL) {
+ fatal(MYNAME ": Cannot open %s for reading\n", fname );
+ }
+ }
+ else {
+ fd = NULL;
+ input_string = fname+1;
+ input_string_len = strlen(input_string);
}
if (get_option(args, "logpoint") != NULL)
if ( cdatastr ) {
xfree(cdatastr);
}
- fclose(fd);
+ if (fd) {
+ fclose(fd);
+ }
}
void
int len;
int done = 0;
char buf[MY_CBUF];
+ int result = 0;
while (!done) {
- len = fread(buf, 1, sizeof(buf), fd);
- done = feof(fd) || !len;
- if (!XML_Parse(psr, buf, len, done)) {
+ if ( fd ) {
+ len = fread(buf, 1, sizeof(buf), fd);
+ done = feof(fd) || !len;
+ result = XML_Parse(psr, buf, len, done);
+ }
+ else if (input_string) {
+ done = 0;
+ result = XML_Parse(psr, input_string,
+ input_string_len, done );
+ done = 1;
+ }
+ else {
+ done = 1;
+ result = -1;
+ }
+ if (!result) {
fatal(MYNAME ": XML parse error at %d: %s\n",
XML_GetCurrentLineNumber(psr),
XML_ErrorString(XML_GetErrorCode(psr)));
static
arglist_t gpx_args[] = {
- { "gsshortnames", &gsshortnames, "Prefer shorter descriptions from Groundspeak files"},
- { "snlen", &snlen, "Length of generated shortnames" },
- { "suppresswhite", &suppresswhite, "Suppress whitspace in generated shortnames" },
- { 0, 0, 0}
+ { "gsshortnames", &gsshortnames,
+ "Prefer shorter descriptions from Groundspeak files",
+ ARGTYPE_BOOL },
+ { "snlen", &snlen, "Length of generated shortnames", ARGTYPE_INT },
+ { "suppresswhite", &suppresswhite,
+ "Suppress whitespace in generated shortnames", ARGTYPE_BOOL },
+ { 0, 0, 0, 0 }
};
ff_vecs_t gpx_vecs = {
static
arglist_t mag_args[] = {
- {"baud", &bs, "Numeric value of bitrate (baud=4800)"},
- {"noack", &noack, "Suppress use of handshaking in name of speed"},
- {"deficon", &deficon, "Default icon name"},
- {0, 0, 0}
+ {"baud", &bs, "Numeric value of bitrate (baud=4800)", ARGTYPE_INT },
+ {"noack", &noack, "Suppress use of handshaking in name of speed",
+ ARGTYPE_BOOL},
+ {"deficon", &deficon, "Default icon name", ARGTYPE_STRING },
+ {0, 0, 0, 0}
};
static void
static
arglist_t mps_args[] = {
- {"snlen", &snlen, "Length of generated shortnames" },
- {0, 0, 0}
+ {"snlen", &snlen, "Length of generated shortnames", ARGTYPE_INT },
+ {0, 0, 0, 0}
};
const char *
static
arglist_t pcx_args[] = {
- {"deficon", &deficon, "Default icon name"},
- {0, 0, 0}
+ {"deficon", &deficon, "Default icon name", ARGTYPE_STRING },
+ {0, 0, 0, 0}
};
static void
static
arglist_t polygon_args[] = {
- {"file", &polyfileopt, "File containing vertices of polygon"},
- {"exclude", &exclopt, "Exclude points inside the polygon"},
- {0, 0, 0}
+ {"file", &polyfileopt, "File containing vertices of polygon",
+ ARGTYPE_FILE | ARGTYPE_REQUIRED },
+ {"exclude", &exclopt, "Exclude points inside the polygon",
+ ARGTYPE_BOOL },
+ {0, 0, 0, 0}
};
static void polytest ( double lat1, double lon1,
static
arglist_t position_args[] = {
- {"distance", &distopt, "Maximum positional distance (required)"},
- {0, 0, 0}
+ {"distance", &distopt, "Maximum positional distance",
+ ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+ {0, 0, 0, 0}
};
static
arglist_t radius_args[] = {
- {"lat", &latopt, "Latitude for center point (D.DDDDD)"},
- {"lon", &lonopt, "Longitude for center point (D.DDDDD)"},
- {"distance", &distopt, "Maximum distance from center"},
- {"exclude", &exclopt, "Exclude points close to center"},
- {0, 0, 0}
+ {"lat", &latopt, "Latitude for center point (D.DDDDD)",
+ ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+ {"lon", &lonopt, "Longitude for center point (D.DDDDD)",
+ ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+ {"distance", &distopt, "Maximum distance from center",
+ ARGTYPE_FLOAT | ARGTYPE_REQUIRED },
+ {"exclude", &exclopt, "Exclude points close to center",
+ ARGTYPE_BOOL },
+ {0, 0, 0, 0}
};
static double
static
arglist_t quovadis_args[] = {
- {"dbname", &dbname, "Database name"},
- {0, 0, 0}
+ {"dbname", &dbname, "Database name", ARGTYPE_STRING},
+ {0, 0, 0, 0}
};
static struct qv_icon_mapping mapping[] = {
static
arglist_t tiger_args[] = {
- {"nolabels", &nolabels, "Suppress labels on generated pins."},
- {"genurl", &genurl, "Generate file with lat/lon for centering map."},
- {"scale", &scale, "Dimension in pixels of map."},
+ {"nolabels", &nolabels, "Suppress labels on generated pins.",
+ ARGTYPE_BOOL },
+ {"genurl", &genurl, "Generate file with lat/lon for centering map.",
+ ARGTYPE_OUTFILE },
+ {"scale", &scale, "Dimension in pixels of map.",
+ ARGTYPE_INT},
#if CLICKMAP
- {"clickmap", &clickmap, "Generate Clickable map web page."},
+ {"clickmap", &clickmap, "Generate Clickable map web page.",
+ ARGTYPE_BOOL},
#endif
- {0, 0, 0}
+ {0, 0, 0, 0}
};
for (vec = vec_list; vec->vec; vec++) {
printf(VEC_FMT, vec->name, vec->desc);
for (ap = vec->vec->args; ap && ap->argstring; ap++) {
- printf(" %-18.18s %-.50s\n",
- ap->argstring, ap->helpstring);
+ printf(" %-18.18s %-.50s %s\n",
+ ap->argstring, ap->helpstring,
+ (ap->argtype & ARGTYPE_REQUIRED)?"(required)":"");
}
}
static
arglist_t xcsv_args[] = {
- {"style", &styleopt, "Full path to XCSV style file (required)"},
- {"snlen", &snlenopt, "Max synthesized shortname length"},
- {"snwhite", &snwhiteopt, "(0/1) Allow whitespace synth. shortnames"},
- {"snupper", &snupperopt, "(0/1) UPPERCASE synth. shortnames"},
- {"snunique", &snuniqueopt, "(0/1) Make synth. shortnames unique"},
- {"urlbase", &xcsv_urlbase, "Basename prepended to URL on output"},
- {"prefer_shortnames", &prefer_shortnames, "Use shortname instead of description"},
- {0, 0, 0}
+ {"style", &styleopt, "Full path to XCSV style file",
+ ARGTYPE_FILE | ARGTYPE_REQUIRED },
+ {"snlen", &snlenopt, "Max synthesized shortname length",
+ ARGTYPE_INT},
+ {"snwhite", &snwhiteopt, "(0/1) Allow whitespace synth. shortnames",
+ ARGTYPE_BOOL},
+ {"snupper", &snupperopt, "(0/1) UPPERCASE synth. shortnames",
+ ARGTYPE_BOOL},
+ {"snunique", &snuniqueopt, "(0/1) Make synth. shortnames unique",
+ ARGTYPE_BOOL},
+ {"urlbase", &xcsv_urlbase, "Basename prepended to URL on output",
+ ARGTYPE_STRING},
+ {"prefer_shortnames", &prefer_shortnames,
+ "Use shortname instead of description", ARGTYPE_BOOL },
+ {0, 0, 0, 0}
};
/* a table of config file constants mapped to chars */